

package cn.shengchao.examstart.user.domain.entity;

import cn.shengchao.examstart.user.domain.vlobj.SocialSourceEnum;
import lombok.Data;

import java.time.LocalDateTime;

@Data
public class UserSocial {
    /**
     * 来源
     */
    private String source;

    /**
     * 应用id
     */
    private String appId;

    /**
     * 统一 ID
     */
    private String unionId;

    /**
     * 开放 ID
     */
    private String openId;

    /**
     * 附加信息
     */
    private String metaJson;

    /**
     * 最后登录时间
     */
    private LocalDateTime lastLoginTime;

    public static UserSocial of(SocialSourceEnum socialSourceEnum, String appid, String openId, String unionId) {
        UserSocial userSocial = new UserSocial();
        userSocial.source = socialSourceEnum.getSource();
        userSocial.appId = appid;
        userSocial.openId = openId;
        userSocial.lastLoginTime = LocalDateTime.now();
        userSocial.unionId = unionId;
        return userSocial;
    }
}
